import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKBthSNZbr9gtRT8ywkcbJLbAFDiMNgm47+Uj4TIQcYsNlRjRgbhivsu9r0M9ImXQByc7/sID1VXdlOB0sLQBhkCAwEAAQ==' 

const privateKey = 
'MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAoG2FI1luv2C1FPzL'+
'CRxsktsAUOIw2Cbjv5SPhMhBxiw2VGNGBuGK+y72vQz0iZdAHJzv+wgPVVd2U4HS'+
'wtAGGQIDAQABAkEAipt1b4BChkkYy0RKa9nKGOvsjvWOvAKFva2ufkvDQGLt91CP'+
'0hXdnZx9eQreJega7Ld6Ou1ZK93p5EnD6jq5nQIhANWDx7Nk0wGp3N2Uh3+AJPqb'+
'bNY/0jgZM0mpuPZfxgzrAiEAwFmLvTprmcgN3W+usGQuB8Km7NSCCPGcLhBZF9Sq'+
'aAsCIQC7DPW4nY2VmYAaxnJmKpc6zUrt7391Ee6yi/O0M3dH/QIgPOadNeafVute'+
'aHQJ7VNqt45L58RI/6fv+S2357Gv2o0CIDgSzINqqyMpuXO0nNw1ZsFgRL3To7Ty'+
'9VdRK9IKvJyu'

// 加密
export function encrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPrivateKey(privateKey) // 设置私钥
    return encryptor.decrypt(txt) // 对数据进行解密
}
